//
//  XVImageView.m
//  整合
//
//  Created by  刘尚威 on 2017/3/3.
//  Copyright © 2017年  刘尚威. All rights reserved.
//

#import "XVImageView.h"

@implementation XVImageView

+ (UIImageView *)ImageViewWithImageName:(NSString *)imageName
                        backgroundColor:(UIColor *)backgroundColor
                            contentMode:(UIViewContentMode)contentMode
                              addToView:(UIView *)view
                                  frame:(CGRect)frame
{
    UIImageView *newImageView = [[UIImageView alloc] initWithFrame:frame];
    
    //设置图片
    if (newImageView != nil) {
        newImageView.image = [UIImage imageNamed:imageName];
    }
    
    //imageView的背景色
    if (backgroundColor == nil) {
        newImageView.backgroundColor = [UIColor clearColor];
    }
    else {
        newImageView.backgroundColor = backgroundColor;
    }
    
    //设置图片的拉伸方式
    newImageView.contentMode = contentMode;
    
    if (view != nil) {
        [view addSubview:newImageView];
    }
    
    return newImageView;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
